package com.bjpowernode.test01;

import java.util.Scanner;

//判断键盘输入数字的正负性、奇偶性
public class Task4 {
    public static void main(String[] args) {
//        verNum();
//        verTaxi();
//        verSeason();
//        printNum();
        verCount(100);


    }

    //定义方法，判断输入数字的正负性、奇偶性
    public static void verNum(){
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个数字：");
        int num = sc.nextInt();
        if (num%2==0 & num>0){
            System.out.println("输入的是正数、偶数");
        }else if (num%2==0 & num<0){
            System.out.println("输入的是负数、偶数");
        }else if (num%2==1 & num>0){
            System.out.println("输入的是正数、奇数");
        }else if (num%2==1 & num<0){
            System.out.println("输入的是负数、奇数");
        }else {
            System.out.println("输入的是0");
        }
    }

    //定义方法，判断车费
    public static void verTaxi(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入里程数: ");
        Double way = sc.nextDouble();
        Double price;
        if (way>0 & way<=3){
            System.out.println("车费是8元");
        }else if (way<=5){
            price = 8 + (way-3)*1.2;
            System.out.println("车费是"+price+"元");
        }else if (way>5){
            price = 8 + 2*1.2 + (way-5)*1.5;
            System.out.println("车费是"+price+"元");
        }else {
            System.out.println("您的输入有误");
        }
    }

    //判断输入月份所属的季节
    public static void verSeason(){
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入月份数: ");
        int month = sc.nextInt();
        switch (month){
            case 3 : case 4 : case 5 :
                System.out.println("春季");
                break;
            case 6 : case 7 : case 8 :
                System.out.println("夏季");
                break;
            case 9 : case 10: case 11:
                System.out.println("秋季");
                break;
            case 12: case 1 : case 2 :
                System.out.println("冬季");
                break;
            default:
                System.out.println("您的输入有误");
        }
    }

    public static void printNum(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要打印的行数: ");
        int num = sc.nextInt();
        for (int i=1;i<=num;i++){
            System.out.println(i+"   "+i*10+"  "+i*100+i*1000);
        }
    }

    //打印2到100之间的素数
    public static void verCount(int num){
        int count = 0;
        for (int i=2;i<=num;i++){
            if (verSu(i)){
                System.out.print(i+" ");
                count++;
            }
            if (count%5 == 0){
                System.out.println();
            }
        }
    }

    //判断素数的方法
    public static boolean verSu(int num){
        for (int i=2;i<num-1;i++){
            if (num%i==0){
                return false;
            }
        }
        return true;
    }






}
